package com.example.reactor;

import reactor.core.publisher.Mono;

public class MonoEmptyTest {
    public static void main(String[] args) {
        System.out.println("Testing Mono.empty() behavior in different operators:");

        // 创建一个 Mono.empty()
        Mono<Void> emptyMono = Mono.empty();

        // 1. 测试 then 操作符
        emptyMono
                .then(Mono.fromRunnable(() -> System.out.println("Entered then operator")))
                .subscribe();

        // 2. 测试 flatMap 操作符
        emptyMono
                .flatMap(result -> {
                    System.out.println("Entered flatMap operator");
                    return Mono.just("FlatMap operator triggered");
                })
                .subscribe();

        // 3. 测试 delayUntil 操作符
        emptyMono
                .delayUntil(result -> {
                    System.out.println("Entered delayUntil operator");
                    return Mono.just("Delayed operator triggered");
                })
                .subscribe();

        // 4. 测试 switchIfEmpty 操作符
        emptyMono
                .switchIfEmpty(Mono.fromRunnable(() -> System.out.println("Entered switchIfEmpty operator")))
                .subscribe();
    }
}
